home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14035 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: tst.hk.super.net!usenet
  2. From: chiasw@hk.super.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Please help me to sort 'adjacent items'
  5. Date: 28 Mar 1996 15:34:36 GMT
  6. Organization: Hong Kong SuperNET
  7. Message-ID: <4jebic$jn5@tst.hk.super.net>
  8. NNTP-Posting-Host: max2-17.hk.super.net
  9. X-Newsreader: AIR News 3.X (SPRY, Inc.)
  10.  
  11. I have a sorting problem and is looking for a quick solution:
  12. Consider the following  table represents some adjacency information:
  13.  
  14.  B - C
  15.  C - L
  16.  D - E
  17.  E - M
  18.  F - G
  19.  G - N
  20.  H - K
  21.  I - M
  22.  J - K
  23.  J - L
  24.  M - O
  25.  N - O
  26.  
  27.  that is, item B is adjacent to C, C is adjacent to L, D is adjacent to E
  28.  etc.
  29.  
  30.  The problem is now to sort all items which are directly adjacent to each 
  31.  other into different groups, therefore, they should be sorted into
  32.  two groups:
  33.   B - C - L - J - K - H
  34.   and
  35.   O - N - M - I - E - D - G - F
  36.  
  37.  For we human, the problem can be done easily on paper by inspection.
  38.  Is there any simple algorithm to implement this sort of sorting on 
  39.  computer?
  40.  
  41.  Please lend me some help. Many thanks!
  42.  
  43.  SW Chia
  44.  email: chiasw@hk.super.net
  45.  
  46.  
  47.  
  48.